package com.witframework.web.tag.fieldsettag;


import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTagSupport;
/**
 *<PRE> <%@ taglib uri="taglib.tld" prefix="f" %>
		<f:fieldset>
 			<f:caption>Health information:</f:caption>
 			<f:body>
 				Height <input type="text" size="3">
 				Weight <input type="text" size="3">
 			</f:body>
		</f:fieldset>
</PRE> 
 * @author wuxinyang
 * Aug 17, 2009 9:03:31 AM
 *
 */
public class FieldsetTag extends BodyTagSupport
{
  private String align = null;
  private String legend = null;
  private String dataBody = null;

  public void setAlign(String paramString)
  {
    this.align = paramString;
  }

  public String getAlign()
  {
    return this.align;
  }

  public void setLegend(String paramString)
  {
    this.legend = paramString;
  }

  public void setDataBody(String paramString)
  {
    this.dataBody = paramString;
  }

  public int doAfterBody()
    throws JspTagException
  {
    BodyContent localBodyContent = getBodyContent();
    if (localBodyContent != null)
      localBodyContent.clearBody();
    return 0;
  }

  public int doEndTag()
    throws JspTagException
  {
    StringBuffer localStringBuffer = new StringBuffer();
    localStringBuffer.append("<fieldset");
    if (this.align != null)
    {
      localStringBuffer.append(" align=\"");
      localStringBuffer.append(this.align);
      localStringBuffer.append("\"");
    }
    localStringBuffer.append(">\n");
    if (this.legend != null)
      localStringBuffer.append(this.legend);
    if (this.dataBody != null)
      localStringBuffer.append(this.dataBody);
    localStringBuffer.append("\n");
    localStringBuffer.append("</fieldset>\n");
    try
    {
      this.pageContext.getOut().write(localStringBuffer.toString());
    }
    catch (Exception localException)
    {
      throw new JspTagException("fieldset tag: could not write data: " + localException.toString());
    }
    dropData();
    return 6;
  }

  public void release()
  {
    dropData();
  }

  private void dropData()
  {
    this.align = null;
    this.legend = null;
    this.dataBody = null;
  }
}
